<template>
	<el-dialog title="" width="60%" visible :show-close="false" :append-to-body="true" class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		<div class="bt">批量布置作业</div>
		<el-form label-width="100px" class="form">
			<div class="left" style="width: 30%;float: left;border-right:1px dashed #000;">
				<span style="font-size:20px;margin-left: 41%;">物品</span>
				<p style="border-bottom: 1px solid #969696;"></p>
				<ul>
					<li v-for='v in this.params.list'>{{v.kcmc}} {{v.jcmc}} {{v.day}}</li>
				</ul>
			</div>
			<div class="right" style="width: 70%;float: right;">
				<span style="font-size:20px;margin-left: 45%;">作业内容</span>
				<el-form-item label="作业内容">
					<el-input v-model="form.nr" type="textarea" :rows="4" placeholder="请输入" class="select-block"></el-input>
				</el-form-item>
			</div>

		</el-form>
		<el-button type="primary" class="submit" @click="submit">保存</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
		
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {

				form: {
					nr: '',
					id: '',
				},
				zyid: '',
			}
		},
		created() {
			console.log(this.params)
			var arr = []
			this.params.list.forEach(function(v, i) {
				arr.push(v.id)
			})
			this.zyid = arr.join(",");
		},
		methods: {
			submit() {
				//检测
				this.$store.state.loading = true;
				if(!this.form.nr) {
					this.$message.warning('请填写作业内容！');
					this.$store.state.loading = false;
					return;
				}
				//装载数据
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					ids: this.zyid,
					nr: this.form.nr,
					yhid: logininfo.id,
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'bjjczymodel/update1', params2)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', {type: 'plwp',cancel: false,id:this.params.id});
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
							this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器异常");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', {
					type: 'plwp',
					cancel: true
				})
			}
		},
	}
</script>
<style lang="less" scoped>
	.wrap {
		text-align: center;
	}
	
	.bt {
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		margin-bottom: 20px;
		color: white;
		text-align: left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}
	
	.form {
		overflow: hidden;
		text-align: left;
		margin-top: 20px;
	}
	
	.jclt {
		width: 85%;
		height: 50px;
		float: left;
		font-size: 16px;
		text-align: center;
		line-height: 50px;
		/*border-right: 1px solid #CCCCCC;*/
		cursor: pointer;
	}
	
	.input {
		display: inline-block;
	}
	
	.select-block {
		display: block;
		width: 85%;
	}
	
	.submit {
		width: 120px;
	}
	
	li {
		text-align: center;
	}
</style>